package br.com.async.core.infrastructure;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import br.com.async.core.domain.user.User;
import br.com.async.core.domain.user.UserRepository;

public class UserRepositoryImpl extends AbstractRepositoryImpl<User, Integer> implements UserRepository{

	public UserRepositoryImpl() {
		super(User.class);
	}

	@Override
	public User doLogin(String hash) {
		
		Criteria criteria = getSession().createCriteria(entityClass);
		Criterion c1 = Restrictions.eq("password", hash);
		
		criteria.add(c1);
		
		return (User) criteria.uniqueResult();
	}

}
